#include <REGX52.H>
#include "Delay.h"
#include "Nixie.h"
#include "Timer0.h"
#include "KeyTimer0.h"

sbit DA = P2^1;//直流电机


unsigned char Counter,Compare;//前者计数，后者作为比较变量
unsigned char i;

void main()
{
	Timer0_Init();
	
	while(1)
	{
		
		for(i=0;i<100;i++)
		{
			Compare = i;
			Delay(10);
		}
		for(i=100;i>0;i--)
		{
			Compare = i;
			Delay(10);
		}
		
		
	}
	
}

void Timer0_Routine() interrupt 1  //定时器0的中断函数
{
	static unsigned int anjian;
	
	TL0 = 0xA4;		//100us进入一次
	TH0 = 0xFF;		
	Counter++;
	anjian++;
	if(anjian>=10)//10ms,扫描一次按键
	{
		KeyScan();
		anjian=0;
	}
	if(Counter >= 100) Counter = 0;
	if(Counter < Compare) {DA = 1;}
	else {DA = 0;}
}

